﻿@model Supplier
@{
    ViewBag.Title = "Index";
}

<h2>Supplier Manager</h2>

<div role="tabpanel">

    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#edit" aria-controls="edit" role="tab" data-toggle="tab">Supplier Edition</a></li>
        <li role="presentation"><a href="#list" aria-controls="list" role="tab" data-toggle="tab">List of Suppliers</a></li>
    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="edit">
            <h4>@Html.ValidationSummary()</h4>
            @using (Html.BeginForm("Insert", "Supplier",
    FormMethod.Post, new { enctype = "multipart/form-data" }))
            {
                <div class="form-group">
                    <div>Id</div>
                    @Html.TextBoxFor(s => s.Id, new { @class = "form-control" })
                </div>

                <div class="form-group">
                    <div>Company Name</div>
                    @Html.TextBoxFor(s => s.Name, new { @class = "form-control" })
                </div>

                <div class="form-group">
                    <div>Phone Number</div>
                    @Html.TextBoxFor(s => s.Phone, new { @class = "form-control" })
                </div>

                <div class="form-group">
                    <div>Email Address</div>
                    @Html.TextBoxFor(s => s.Email, new { @class = "form-control" })
                </div>

                <div class="form-group">
                    <div>Logo</div>
                    <img src="/images/suppliers/@Model.Logo" /><br />
                    <input type="file" name="UpPhoto" />
                    @Html.HiddenFor(s => s.Logo)
                </div>

                <div class="form-group">
                    <div></div>
                    <div>
                        <button onclick="form.action='/Adm/Supplier/Insert'" class="btn btn-default">Insert</button>
                        @if (!String.IsNullOrEmpty(Model.Id))
                        {
                            <button onclick="form.action='/Adm/Supplier/Update'" class="btn btn-default">Update</button>
                            <a href="/Adm/Supplier/Delete/@Model.Id" class="btn btn-default">Delete</a>
                        }
                        <a href="/Adm/Supplier/Index" class="btn btn-default">Reset</a>
                    </div>
                </div>
            }
        </div>
        <div role="tabpanel" class="tab-pane" id="list">
            <table class="table">
                <tr>
                    <th>Id</th>
                    <th>Name</th>
                    <th>Email</th>
                    <th>Phone</th>
                    <th>Logo</th>
                    <th></th>
                </tr>
                @foreach (var s in ViewBag.Suppliers)
                {
                    <tr>
                        <td>@s.Id</td>
                        <td>@s.Name</td>
                        <td>@s.Email</td>
                        <td>@s.Phone</td>
                        <td>@s.Logo</td>
                        <th>
                            <a href="/Adm/Supplier/Edit/@s.Id"
                               class="btn btn-default">Edit</a>
                        </th>
                    </tr>
                }
            </table>
        </div>
    </div>

</div>



